```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java内存模型详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }
        .highlight {
            background: linear-gradient(90deg, rgba(255,255,255,0) 50%, rgba(255,214,102,0.5) 50%);
            background-size: 200%;
            transition: all 0.3s ease;
        }
        .highlight:hover {
            background-position: -100%;
        }
        .memory-icon {
            font-size: 1.5rem;
            margin-right: 0.5rem;
            color: #667eea;
        }
        .section-divider {
            height: 1px;
            background: linear-gradient(90deg, rgba(102,126,234,0) 0%, rgba(102,126,234,0.5) 50%, rgba(102,126,234,0) 100%);
            margin: 3rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <div class="hero text-white py-20 px-4">
        <div class="container mx-auto max-w-4xl">
            <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">深入理解Java内存模型</h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">探索多线程环境下内存管理的核心机制</p>
            <div class="bg-white bg-opacity-20 p-6 rounded-lg backdrop-filter backdrop-blur-sm">
                <p class="text-lg">Java内存模型定义了Java程序中多线程并发访问共享内存的规范，确保在不同平台上的一致性。理解内存结构是掌握Java并发编程的基础。</p>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto max-w-4xl px-4 py-12">
        <!-- Memory Areas Section -->
        <section>
            <h2 class="text-3xl font-bold mb-8 flex items-center">
                <i class="fas fa-memory memory-icon"></i>
                <span>主要内存区域</span>
            </h2>
            
            <div class="grid md:grid-cols-2 gap-6 mb-12">
                <!-- Heap Card -->
                <div class="card bg-white p-6 rounded-lg">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-red-100 rounded-full flex items-center justify-center text-red-600 mr-4">
                            <i class="fas fa-database text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">堆 (Heap)</h3>
                    </div>
                    <p class="mb-4">堆是Java程序中最大的内存区域，用于存储对象实例和数组。所有线程共享堆内存，GC（Garbage Collection）负责管理堆内存中的对象。</p>
                    <div class="bg-gray-50 p-4 rounded">
                        <ul class="list-disc pl-5 space-y-1">
                            <li>存储对象实例和数组</li>
                            <li>所有线程共享</li>
                            <li>由GC管理，负责对象的创建、分配和回收</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Stack Card -->
                <div class="card bg-white p-6 rounded-lg">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center text-blue-600 mr-4">
                            <i class="fas fa-layer-group text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">栈 (Stack)</h3>
                    </div>
                    <p class="mb-4">栈是线程私有的内存区域，存储局部变量、方法调用、方法返回值等。每个线程都有自己的栈，栈中的数据由线程的执行顺序决定。</p>
                    <div class="bg-gray-50 p-4 rounded">
                        <ul class="list-disc pl-5 space-y-1">
                            <li>存储局部变量、方法调用、方法返回值</li>
                            <li>每个线程独占</li>
                            <li>数据随着方法的入栈和出栈动态变化</li>
                        </ul>
                    </div>
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-6">
                <!-- Method Area Card -->
                <div class="card bg-white p-6 rounded-lg">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center text-purple-600 mr-4">
                            <i class="fas fa-code text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">方法区 (Method Area)</h3>
                    </div>
                    <p class="mb-4">方法区也是线程共享的内存区域，用于存储类信息、静态变量、常量池等。在HotSpot虚拟机中，方法区被称为永久代（PermGen）。</p>
                    <div class="bg-gray-50 p-4 rounded">
                        <ul class="list-disc pl-5 space-y-1">
                            <li>存储类信息、静态变量、常量池</li>
                            <li>所有线程共享</li>
                            <li>在HotSpot中称为永久代</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Runtime Constant Pool Card -->
                <div class="card bg-white p-6 rounded-lg">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-green-100 rounded-full flex items-center justify-center text-green-600 mr-4">
                            <i class="fas fa-cubes text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">运行时常量池</h3>
                    </div>
                    <p class="mb-4">运行时常量池是方法区的一部分，存储着类文件中的常量信息，包括字符串常量、类、方法、字段等。在运行时，每个类都有自己的运行时常量池。</p>
                    <div class="bg-gray-50 p-4 rounded">
                        <ul class="list-disc pl-5 space-y-1">
                            <li>存储类文件中的常量信息</li>
                            <li>每个类都有自己的运行时常量池</li>
                            <li>可以动态添加新的常量</li>
                        </ul>
                    </div>
                </div>
            </div>
            
            <!-- Memory Diagram -->
            <div class="mt-16">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-project-diagram memory-icon"></i>
                    <span>内存区域关系图</span>
                </h3>
                <div class="bg-white p-6 rounded-lg shadow">
                    <div class="mermaid">
                        graph TD
                            A[Java内存模型] --> B[堆 Heap]
                            A --> C[栈 Stack]
                            A --> D[方法区 Method Area]
                            D --> E[运行时常量池]
                            style A fill:#f8fafc,stroke:#333,stroke-width:2px
                            style B fill:#fee2e2,stroke:#f87171
                            style C fill:#dbeafe,stroke:#60a5fa
                            style D fill:#ede9fe,stroke:#8b5cf6
                            style E fill:#dcfce7,stroke:#4ade80
                    </div>
                </div>
            </div>
        </section>
        
        <div class="section-divider"></div>
        
        <!-- Object Memory Analysis -->
        <section>
            <h2 class="text-3xl font-bold mb-8 flex items-center">
                <i class="fas fa-cube memory-icon"></i>
                <span>对象的内存分析</span>
            </h2>
            
            <div class="mb-8">
                <p class="mb-4">要理解Java的内存划分，我们重点关注三个区域：<span class="font-bold text-blue-600">栈</span>、<span class="font-bold text-red-600">堆</span>和<span class="font-bold text-purple-600">方法区</span>。</p>
                
                <div class="bg-white p-6 rounded-lg shadow mb-8">
                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692781017027-16bf251a-8434-4d4c-9aa0-354bb3a59638.png" alt="Java内存区域示意图" class="w-full rounded">
                </div>
                
                <div class="grid md:grid-cols-3 gap-4 mb-8">
                    <div class="bg-red-100 text-red-800 p-4 rounded-lg">
                        <h4 class="font-bold mb-2">栈 (Stack)</h4>
                        <p>存放局部变量（方法参数或者方法定义的变量）</p>
                    </div>
                    <div class="bg-blue-100 text-blue-800 p-4 rounded-lg">
                        <h4 class="font-bold mb-2">堆 (Heap)</h4>
                        <p>存放new出来的对象</p>
                    </div>
                    <div class="bg-purple-100 text-purple-800 p-4 rounded-lg">
                        <h4 class="font-bold mb-2">方法区</h4>
                        <p>存放类字节码信息</p>
                    </div>
                </div>
            </div>
            
            <!-- Case Studies -->
            <div class="mb-12">
                <h3 class="text-2xl font-bold mb-6 text-red-600">
                    <i class="fas fa-search-plus mr-2"></i>案例分析
                </h3>
                
                <div class="space-y-12">
                    <!-- Case 1 -->
                    <div>
                        <h4 class="text-xl font-bold mb-4 flex items-center">
                            <span class="bg-red-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">1</span>
                            创建单个对象的情况
                        </h4>
                        <div class="bg-white p-6 rounded-lg shadow">
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692781017300-d58cc5a2-4de9-49ab-ae24-3df3e512cff7.png" alt="单个对象内存分析" class="w-full rounded">
                        </div>
                    </div>
                    
                    <!-- Case 2 -->
                    <div>
                        <h4 class="text-xl font-bold mb-4 flex items-center">
                            <span class="bg-red-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">2</span>
                            创建多个对象的情况
                        </h4>
                        <div class="bg-white p-6 rounded-lg shadow">
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692781017562-76c14332-2902-445e-bee3-a510f9768caf.png" alt="多个对象内存分析" class="w-full rounded">
                        </div>
                    </div>
                    
                    <!-- Case 3 -->
                    <div>
                        <h4 class="text-xl font-bold mb-4 flex items-center">
                            <span class="bg-red-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">3</span>
                            传递基本数据类型的情况
                        </h4>
                        <div class="grid md:grid-cols-2 gap-4">
                            <div class="bg-white p-4 rounded-lg shadow">
                                <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692781017827-c6f99cbd-d1d0-4a95-a00c-de233eace36a.png" alt="基本数据类型传递1" class="w-full rounded">
                            </div>
                            <div class="bg-white p-4 rounded-lg shadow">
                                <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692781018094-71fef369-ccac-47e5-bdf7-62d3c12a2164.png" alt="基本数据类型传递2" class="w-full rounded">
                            </div>
                        </div>
                    </div>
                    
                    <!-- Case 4 -->
                    <div>
                        <h4 class="text-xl font-bold mb-4 flex items-center">
                            <span class="bg-red-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">4</span>
                            传递引用类型的情况
                        </h4>
                        <p class="mb-4 italic text-gray-600">引用类型：String、class、数组</p>
                        <div class="bg-white p-6 rounded-lg shadow">
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692781018341-4d689572-5a7e-4109-a7a1-64eeb6049ba4.png" alt="引用类型传递" class="w-full rounded">
                        </div>
                    </div>
                    
                    <!-- Case 5 -->
                    <div>
                        <h4 class="text-xl font-bold mb-4 flex items-center">
                            <span class="bg-red-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">5</span>
                            改变change方法后的情况
                        </h4>
                        <div class="bg-yellow-50 p-4 rounded-lg mb-4">
                            <div class="font-mono text-sm bg-gray-800 text-gray-100 p-3 rounded overflow-x-auto">
                                <span class="text-blue-400">public</span> <span class="text-blue-400">void</span> <span class="text-yellow-300">change</span>(Student student){<br/>
                                &nbsp;&nbsp;&nbsp;&nbsp;student = <span class="text-blue-400">new</span> Student();<br/>
                                &nbsp;&nbsp;&nbsp;&nbsp;student.setAge(<span class="text-green-400">18</span>);<br/>
                                }
                            </div>
                        </div>
                        <p class="mb-4">使得前后的两个对象指向了不同的内存区域</p>
                        <div class="bg-white p-6 rounded-lg shadow">
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692781018563-bf035748-6eef-4bfe-83db-a4b0debefe95.png" alt="改变方法后的内存变化" class="w-full rounded">
                        </div>
                    </div>
                </div>
            </div>
        </section>
        
        <div class="section-divider"></div>
        
        <!-- Array Memory Analysis -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 flex items-center">
                <i class="fas fa-bars memory-icon"></i>
                <span>数组的内存分析</span>
            </h2>
            
            <p class="mb-6">数组是引用类型的一种重要表现形式，理解其内存分配对于掌握Java编程至关重要。</p>
            
            <div class="bg-white p-6 rounded-lg shadow">
                <h3 class="text-xl font-bold mb-4">对象数组的内存布局</h3>
                <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692781018868-ecd055b6-741d-4de4-b444-50ac94aacde7.png" alt="对象数组内存分析" class="w-full rounded">
            </div>
        </section>
        
        <!-- Homework -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 flex items-center">
                <i class="fas fa-tasks memory-icon"></i>
                <span>作业练习</span>
            </h2>
            
            <div class="bg-white p-6 rounded-lg shadow">
                <h3 class="text-xl font-bold mb-4">方法区的应用</h3>
                <p class="mb-6">绘制内存分析图来分析以下场景：</p>
                
                <div class="space-y-6">
                    <div class="p-4 border-l-4 border-blue-500 bg-blue-50">
                        <h4 class="font-bold mb-2">1. 静态属性的内存分析</h4>
                        <p>特点：无论实例化多少个对象只能共享一份静态属性</p>
                    </div>
                    
                    <div class="p-4 border-l-4 border-purple-500 bg-purple-50">
                        <h4 class="font-bold mb-2">2. 字符串常量的比较</h4>
                        <div class="font-mono text-sm bg-gray-100 p-3 rounded overflow-x-auto mb-2">
                            String a = "凤姐";<br/>
                            String b = "凤姐";<br/>
                            System.out.println(a==b); <span class="text-gray-500">// 答案是多少？为什么？</span>
                        </div>
                        <p class="text-sm text-gray-600">提示：考虑方法区中的常量池机制</p>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Summary -->
        <section class="bg-blue-50 p-6 rounded-lg">
            <h2 class="text-2xl font-bold mb-4 flex items-center">
                <i class="fas fa-lightbulb memory-icon"></i>
                <span>关键总结</span>
            </h2>
            <ul class="list-disc pl-5 space-y-2">
                <li>Java内存模型定义了多线程环境下内存访问的规范</li>
                <li>堆存储对象实例，栈存储局部变量，方法区存储类信息</li>
                <li>基本类型传递的是值，引用类型传递的是引用的副本</li>
                <li>字符串常量存储在方法区的常量池中，相同内容的字符串会共享</li>
                <li>理解内存模型有助于编写高效、线程安全的Java程序</li>
            </ul>
        </section>
    </div>
    
    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-8">
        <div class="container mx-auto px-4 text-center">
            <div class="mb-4">
                <h3 class="text-xl font-bold">技术小馆</h3>
                <p class="text-gray-400 mt-2">探索技术的奥秘，分享知识的乐趣</p>
            </div>
            <div class="text-gray-400 hover:text-white transition-colors">
                <a href="http://www.yuque.com/jtostring" target="_blank" class="inline-flex items-center">
                    <i class="fas fa-globe mr-2"></i>
                    <span>http://www.yuque.com/jtostring</span>
                </a>
            </div>
        </div>
    </footer>
    
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 添加微交互效果
        document.querySelectorAll('.highlight').forEach(el => {
            el.addEventListener('mouseenter', function() {
                this.style.backgroundPosition = '-100%';
            });
            el.addEventListener('mouseleave', function() {
                this.style.backgroundPosition = '0%';
            });
        });
    </script>
</body>
</html>
```